/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.server.main;

/**
 *
 * @author ducvt, quandd
 */
public class IdContainer implements IIdContainer {

    private static final Object SyncRoot = new Object();
    private static long index = 0L;

    public IdContainer() {
        index = 0L;
    }

    @Override
    public void reset() {
        synchronized (SyncRoot) {
            index = 0L;
        }
    }

    public long newId() {
        long tmp = 0L;
        synchronized (SyncRoot) {
            tmp = index;
            index++;
        }
        return tmp;
    }
}
